<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script th:src="@{/layui/layui.js}" type="text/javascript"></script>
    <link th:href="@{/layui/css/layui.css}" rel="stylesheet" />
</head>
<body>
<div class="layui-panel">
    <div>
        <table id="regionTable" lay-filter="regionTable"></table>
    </div>
</div>

<script>
    layui.config({
        base:'/js/'
    })
    var $,active;
    layui.use(['table','form','jquery','layer','treeTable'],function(){
        var table = layui.table,layer = layui.layer,form = layui.form,treeTable=layui.treeTable;
        $ = layui.jquery

        var tree = function (){
            treeTable.render({
                elem:'#regionTable',
                url:'/system/rc/findAll',
                height:'full-50',
                tree:{
                    iconIndex:0,
                    isPidData:true,
                    idName:'id',
                    pidName:'pid'
                },
                cols:[
                    [
                        {field:'name',title: '区域名称',width:400,align: 'center'},
                        {field:'type',title:'区域类型',align: 'center',
                            templet:function (res) {
                                var type = res.type;
                                if (type == 1){
                                    return "<span>省</span>";
                                }else if (type == 2){
                                    return "<span>市</span>";
                                }else {
                                    return "<span>区</span>";
                                }
                            }
                        },
                        {field:'code',title: '区域编码',width: 400,align: 'center'}
                    ]
                ]
            })
        }
        tree();
    })

</script>
</body>
</html>